package v1c06;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;

import javax.swing.JOptionPane;
import javax.swing.Timer;

/**
 * @author gjunming@gmail.com
 * @version Aug 5, 2009 5:31:21 PM
 */
public class TimerPrintTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ActionListener myListen = new TimerPrint();
		Timer myTimer = new Timer(1000, myListen);// time unit is microsecond
		myTimer.start();

		JOptionPane.showMessageDialog(null, "Quit!");
		System.exit(1);
	}
}

class TimerPrint implements ActionListener {
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		Date now = new Date();
		System.out.println("Now the time is " + now);
	}
}
